/**
 * 路由处理
 */

export function route(handle, pathname, response , ...args){
	console.log('About to route a request for ' + pathname)
	if(typeof handle[pathname] === 'function'){//路径存在时触发函数
		handle[pathname](args[0])
	} 
	else {//页面不存在时返回404
		console.log('No request handler found for ' + pathname)
	    response.writeHead(404, {'Content-Type': 'text/plain'})
	    response.write('404 Not found')
	}
}
